# This script can convert from a text file to dict
# the text file has the following structure
# asdad = dfsosdg # comment
# sag = dufig # comment
def create_dict_from_file_with_comments(file_path):
    my_dict = {}
    with open(file_path, 'r') as file:
        for line in file:
            # Locate the start of a comment (if any) using '#'
            comment_start = line.find('#')
            # If a comment is found, retain only the text before it and strip whitespace;
            # otherwise, strip whitespace from the entire line
            if comment_start != -1:
                line = line[:comment_start].strip()  # Remove comments and trailing whitespace
            else:
                line = line.strip()
            
            # Proceed as before, but now ignoring empty lines after processing
            if line:  # Ensure the processed line is not empty
                key, value = line.split('=')
                my_dict[key.strip()] = value.strip()
    return my_dict

# Assume your file path is 'example.txt'
file_path = 'example.txt'
my_dict = create_dict_from_file_with_comments(file_path)
print(my_dict)